home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 94 / maccd 94.iso / updates / Logitech / LCCInstallDiskWeb.sit / LCCInstallDiskWeb / Logitech Control Center.pkg / Contents / Resources / VolumeCheck < prev    next >
Encoding:
Text File  |  2002-06-17  |  2.6 KB  |  118 lines  |  [TEXT/????]

  1. #!/usr/bin/perl
  2.  
  3. #20020520.1
  4.  
  5. #goal of this check:
  6. #we'd like to display a error message appropriate is the root volume doesn't have
  7. #an adequate system. I was not able to make this test during the "InstallCheck" script,
  8. #so here we'll let all other disk than the root volume without any error, and check the system version only for the root disk
  9.  
  10.  
  11. $RootVolName = "/";
  12. $VolName = "$ARGV[0]";
  13. $EXIT_VALUE = 0;
  14. $MIN_SYSTEM_VERS = "10.1.1";
  15.  
  16. #open (LOGFILE, ">>/Users/jlavanch/Desktop/PkgTest.log");
  17.  
  18. ($sec, $min, $hour, $mday, $mon, $year, $wday, $ydat, $isdst) = localtime();
  19.  
  20. #print LOGFILE ("$hour:$min:$sec $year-$mon-$mday > ");
  21. #print LOGFILE ("volume checking $VolName \n");
  22.  
  23.  
  24. if ($VolName eq $RootVolName) {
  25. #    print LOGFILE ("$VolName is equal to $RootVolName\n");
  26.     my $TARGET_VOLUME    = "$ARGV[0]";
  27.     my $SYSVERS        = "$TARGET_VOLUME"."/System/Library/CoreServices/SystemVersion.plist";
  28. #    print LOGFILE ("Sysver is in file $SYSVERS\n");
  29.     
  30.     # If system version is Not Greater than minmal required version, show error
  31.     if(!CheckVersion( "$SYSVERS", $MIN_SYSTEM_VERS, "ProductVersion", ">" ))
  32.     {
  33. #        print LOGFILE ("Sysver is lower than $MIN_SYSTEM_VERS\n");
  34.         $EXITVALUE = (( 1 << 5 ) | 17);
  35.     } 
  36.     else {
  37. #        print LOGFILE ("Sysver is greater than or equal to $MIN_SYSTEM_VERS\n");
  38.     } 
  39.             
  40.  
  41. } else {
  42. #    print LOGFILE ("$VolName is NOT equal to $RootVolName\n");
  43. }
  44.  
  45.  
  46. exit( $EXITVALUE );
  47.  
  48. sub CheckVersion
  49. {
  50.     my $path            = $_[0];
  51.     my $version         = $_[1];
  52.     my $keyName            = $_[2];
  53.     my $operator        = $_[3];
  54.  
  55.     if (! -e $path) {
  56.         return 0;
  57.     }
  58.  
  59.     if (!$operator) {
  60.         $operator = "==";
  61.     }
  62.  
  63.     my $oldSeperator = $/;
  64.     $/ = \0;
  65.  
  66.     open( PLIST, "$path") || do {
  67.         return 0;
  68.     };
  69.  
  70.     $plistData = <PLIST>;
  71.     $plistData =~ /<dict>(.*?)<\/dict>/gis;
  72.  
  73.     @items = split(/<key>/, $plistData);
  74.  
  75.     shift @items;
  76.     foreach $item (@items) {
  77.         $item =~ /(.*?)<\/key>.*?<string>(.*?)<\/string>/gis;
  78.         $versiondata{ $1 } = $2;
  79.     }
  80.  
  81.     close(PLIST);
  82.  
  83.     $/ = $oldSeperator;
  84.  
  85.     @theVersionArray = split(/\./, $versiondata{$keyName});
  86.     for ($i = 0; $i < 3; $i++) {
  87.         if(!$theVersionArray[$i]) {
  88.             $theVersionArray[$i] = '0';
  89.         }
  90.     }
  91.  
  92.     @versionArray = split(/\./, $version);
  93.     
  94.     my $actualVersion;
  95.  
  96.     for ($i = 0; $i < 3; $i++) {
  97.         if (($theVersionArray[$i] != $versionArray[$i]) or ($i == 2)) {
  98.  
  99.             $actualVersion = $theVersionArray[$i];
  100.             $version = $versionArray[$i];
  101.  
  102.             last;
  103.         }
  104.     }
  105.  
  106.     my $expression = '$actualVersion ' . $operator . ' $version';
  107.     if( eval ($expression) )
  108.     {
  109.         return 1;
  110.     }
  111.     else
  112.     {
  113.         return 0;
  114.     }
  115.  
  116. }
  117.  
  118.